// index.js
import {
  getArticle
} from '../../api/home'
Page({
  data: {
    swiper: [],
    article:[],
    // channelId=409&pageNo=1&pageSize=3
    query:{
      channelId:409,
      pageNo:1,
      pageSize:3
    }
  },
  onLoad() {

    this.initSwiper()
    this.initArticle()
  },

  async initSwiper() {
    let result = await getArticle(this.data.query)
    if (result.statusCode == 200) {
      let list = result.data.data.list
      list.forEach(item => {
        this.data.swiper.push(item.introPicture)
      });
      this.setData({
        swiper: this.data.swiper
      })
    }
  },
  async initArticle() {
    let result = await getArticle(this.data.query)
    if (result.statusCode == 200) {
      let list = result.data.data.list
      list.forEach(item => {
        this.data.article.push({
          src:item.listView,
          title:item.name,
          content:item.introduction
        })
      });
      this.setData({
        article: this.data.article
      })
      
    }
  },
  more(){
    wx.navigateTo({
      url: '../../home/pages/psychologicalKnowledge/psychologicalKnowledge',
    })
  }

})